// 如果没有通过拦截器配置域名的话，可以在这里写上完整的URL(加上域名部分)
let tokensUrl = 'uaa/v1/auth/tokens';
let smsUrl = 'sms/v1/sms_codes';
let bindMobileUrl = 'uaa/v1/users/op/bind-mobile';
let loginOutUrl = '/uaa/v1/users/op/wx_unbind-mobile';
let allAreaUrl = '/common/v1/all-area-codes';
let ossinitUrl = '/filemeta/v1/inits';
let reruitUrl = '/recruit/v1/myresume';

let jobListUrl = '/recruit/v1/positions';
let jobDetail = '/recruit/v1/positions/';
let applyJob = '/recruit/v1/apply/candidates';
let recommendJob = '/recruit/v1/recommend/candidates';


// 此处第二个参数vm，就是我们在页面使用的this，你可以通过vm获取vuex等操作，更多内容详见uView对拦截器的介绍部分：
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
const install = (Vue, vm) => {

	// 获取Tokens
	let getTokenByCode = (params = {}) => vm.$u.post(tokensUrl, params);

	// 获取短信验证码
	let getSmsCode = (params = {}) => vm.$u.post(smsUrl, params);

	//绑定手机号登录
	let getBindMobile = (params = {}) => vm.$u.post(bindMobileUrl, params);
	
	//退出登录
	let LoginOut = (params = {}) => vm.$u.post(loginOutUrl, params);
	
	//省市区data
	let getallAreaList = (params = {}) => vm.$u.get(allAreaUrl, params);
	
	//OssInit
	let getOssInit = (params = {}) => vm.$u.post(ossinitUrl, Object.assign({}, params, {
		"access_type": "web_upload",
		"action ": "put_object",
		"instance_id": "",
		"object_type": "user_image"
	}));
	
	//编辑简历
	let editReruit = (params = {}) => vm.$u.post(reruitUrl, params);
	
	//获取简历详情
	let getReruitDetails = (params = {}) => vm.$u.get(reruitUrl, params);
	
	//获取职位列表
	let getJobList = (params = {}) => vm.$u.get(jobListUrl,params);
	
	//获取职位详情
	let getJobDetail = (params = {}) => vm.$u.get(jobDetail+params.id);
	
	//申请职位
	let goApplyJob = (params = {}) => vm.$u.post(applyJob,params);
	
	//推荐职位
	let goRecommendJob = (params = {}) => vm.$u.post(recommendJob,params);


	// 将各个定义的接口名称，统一放进对象挂载到vm.$u.api(因为vm就是this，也即this.$u.api)下
	vm.$u.api = {
		getTokenByCode,
		getSmsCode,
		getBindMobile,
		LoginOut,
		getallAreaList,
		getOssInit,
		
		editReruit,
		getReruitDetails,

		getJobList,
		getJobDetail,
		goApplyJob,
		goRecommendJob

	};
}

export default {
	install
}
